﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ASoft.Base
{
    public abstract class AEntity
    {
        public virtual int Id
        {
            get
            {
                return (int)this.GetType().GetProperty(KeyName + "Id").GetValue(this, null);
            }
            set
            {
                this.GetType().GetProperty(KeyName + "Id").SetValue(this, value, null);
            }
        }

        string _KeyName;
        public string KeyName
        {
            get
            {
                if (string.IsNullOrEmpty(_KeyName))
                {
                    _KeyName = this.GetType().Name;
                }
                return _KeyName;
            }
        }
    }
}
